﻿using System.Collections.Generic;
using System.Data;
using Smatime.Web.DAO.SmatimeDatasetTableAdapters;
using Smatime.Web.Models;

namespace Smatime.Web.DAO
{
    public class ViewStaffByCompanyRepository :
        BaseRepository<ViewStaffByCompany, SmatimeDataset.ViewStaffByCompanyDataTable, ViewStaffByCompanyTableAdapter>
    {
        /// <summary>
        ///     Get staff by company id
        /// </summary>
        /// <returns></returns>
        public IEnumerable<ViewStaffByCompany> GetListById(long id)
        {
            using (var adapter = new ViewStaffByCompanyTableAdapter())
            {
                using (var table = adapter.GetDataBy(id))
                {
                    var list = new List<ViewStaffByCompany>();
                    foreach (DataRow row in table.Rows)
                    {
                        var staffsOfCompany = new ViewStaffByCompany();
                        staffsOfCompany.FromDataRow(row);
                        list.Add(staffsOfCompany);
                    }
                    return list;
                }
            }
        }
    }
}